package q2d.server;

import java.io.Serializable;
import java.net.InetAddress;
import java.util.ArrayList;

import q2d.common.models.GameContainer;
import q2d.common.models.units.Bullet;
import q2d.common.models.units.Player;

/* Player representation on server */
public class GamePlayer {
	public InetAddress address;
	public int port;
	public Player player;
	// Bullets of this player.
	public ArrayList<Bullet> bullets = new ArrayList<Bullet>();
	public static final int maxHP = 100;
	private int timeout;
	public int deathCount;
	public int hp;
	
	// Update player with new information.
	public void update(GamePlayer gp) {
		player = gp.player;
		for(Bullet bullet : gp.bullets)
			bullets.add(bullet);
		timeout = 0;
	}
	public GamePlayer(GameContainer gameContainer, InetAddress address) {
		player = gameContainer.getPlayer(0);
		for(int i = 0; i < gameContainer.getBulletsCount(); ++i)
			bullets.add(gameContainer.getBullet(i));
		this.address = address;
		timeout = 0;
		hp = 100;
		deathCount = 0;
	}
	public int getTimeout() {
		return timeout;
	}
	public void setTimeout( int timeout ) {
		this.timeout = timeout;
	}
	public void incTime() {
		timeout += 1;
	}
}
